From 2be8cbdeecb86c61d022f880ada6ff85f81461eb Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 8 Sep 2008 05:06:02 +0000 Subject: [PATCH] Kludge up Mac usb/filesystem transparency on Garmin. Read or write "usb:" on a Colorado or Zumo and the right thing will happen. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3477 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/garmin_device_xml.c | 5 +++-- gpsbabel/jeeps/gpslibusb.c | 41 ++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/gpsbabel/garmin_device_xml.c b/gpsbabel/garmin_device_xml.c index 0e7222b0a..261422d19 100644 --- a/gpsbabel/garmin_device_xml.c +++ b/gpsbabel/garmin_device_xml.c @@ -71,8 +71,9 @@ void dir_s(const char *args, const char **unused) { mountpoint, GB_PATHSEP, path); my_gdx_info->from_device.basename = xstrdup(base); my_gdx_info->from_device.extension = xstrdup(ext); - xasprintf(&my_gdx_info->from_device.canon, "%s.%s", + xasprintf(&my_gdx_info->from_device.canon, "%s/%s.%s", my_gdx_info->from_device.path, + my_gdx_info->from_device.basename, my_gdx_info->from_device.extension); } else if (0 == strcmp(args, "InputToUnit")) { @@ -125,7 +126,7 @@ gdx_find_file(char **dirlist) { const gdx_info *gdx; while (*dirlist) { char *tbuf; - xasprintf(&tbuf, "%s/%s", *dirlist, "GarminDevice.xml"); + xasprintf(&tbuf, "%s/%s", *dirlist, "/Garmin/GarminDevice.xml"); mountpoint = *dirlist; gdx = gdx_read(tbuf); xfree(tbuf); diff --git a/gpsbabel/jeeps/gpslibusb.c b/gpsbabel/jeeps/gpslibusb.c index 3ddb08464..a2c5be780 100644 --- a/gpsbabel/jeeps/gpslibusb.c +++ b/gpsbabel/jeeps/gpslibusb.c @@ -61,6 +61,34 @@ static usb_dev_handle *udev; static int garmin_usb_scan(libusb_unit_data *, int); static const gdx_info *gdx; + +#if __linux__ +static +char ** os_get_garmin_mountpoints() +{ + // Hacked for testing. + return { ".", NULL }; +} +#elif __APPLE__ +// In fantasy land, we'd query iokit for enumerated devices of the Garmin +// vendor ID and match that against the mounted device table. In practical +// matters, that's crazy complex and this is where the devices seems to always +// get mounted... +char ** os_get_garmin_mountpoints() +{ + char **dlist = xcalloc(2, sizeof *dlist); + dlist[0] = xstrdup("/Volumes/GARMIN"); + dlist[1] = NULL; + return dlist; +} +#elif +char ** os_get_garmin_mountpoints() +{ + return {NULL}; +} +#endif + + static int gusb_libusb_send(const garmin_usb_packet *opkt, size_t sz) { @@ -291,11 +319,16 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number) /* Probably too promiscious of a match, but since * Garmin doesn't document the _proper_ matching, * we just take the easy way out for now. + * Unfortunatey, blowing on DeviceClass == Mass storage + * doesn't work on CO, at least. */ if (dev->descriptor.idVendor == GARMIN_VID) { - /* Nuvi */ - if (dev->descriptor.idProduct == 0x19) - continue; + switch (dev->descriptor.idProduct) { + case 0x19: // Nuvi; + case 0x2244: // Zumo; + case 0x2295: // CO; + continue; + } if (req_unit_number < 0) { garmin_usb_start(dev); /* @@ -325,7 +358,7 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number) * that is wants to read and write GPX files on a * mounted drive. Try that now. */ -char *dlist[] = { ".", NULL}; + char **dlist = os_get_garmin_mountpoints(); gdx = gdx_find_file(dlist); if (gdx) return 1; /* Plan C. */ -- 2.30.2